<?php

require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php';
if (isset($phonebook)) {


    if(isset($_POST['post_id'])){
        $post_id = $_POST['post_id'];
        $isChecked = $_POST['isChecked'];
        $current_user = wp_get_current_user();
        $user_id = $current_user->ID;
        $userContact = get_user_meta($user_id,'_userContact', false);
        if(in_array($post_id,$userContact)){
            $result = delete_user_meta($current_user,'_userContact',$post_id);
            die("ok delete");
        }
        else {
            $result = add_user_meta($current_user,'_userContact',$post_id);
            die("ok update");}
    unset($_POST);
    }
}
